function drawPath(data) {
    markerLayer.add([
        {
            'id': 'destination',
            'styleId': 'end',
            'position': new TMap.LatLng(data.destLat, data.destLon)
        }]
    )

    // 构造请求路径网址
    let url = 'https://apis.map.qq.com/ws/direction/v1/walking/'
    url += `?from=${data.originLat},${data.originLon}`
    url += `&to=${data.destLat},${data.destLon}`
    url += `&output=jsonp&callback=callback`
    url += '&key=3GWBZ-ZFWHK-35UJT-AWXBE-UC6BV-3KFFO'

    jsonp_request(url)
}

function jsonp_request(url) {
    let script = document.createElement('script')
    script.src = url
    document.body.appendChild(script)
}

function callback(ret) {
    let coors = ret.result.routes[0].polyline, pl = []
    let kr = 1000000
    for (let i = 2; i < coors.length; i++) {
        coors[i] = Number(coors[i - 2]) + Number(coors[i]) / kr
    }
    for (let i = 0; i < coors.length; i += 2) {

        pl.push(new TMap.LatLng(coors[i], coors[i+1]))
    }
    display_polyline(pl)
}

function display_polyline(pl) {
    // 获取请求的id作为路径的id
    $.ajax({
        url: '/map/getFirstAssigned',
        type: 'get',
        success: data => {
            polylineLayer.add([{
                'id': `${data.h_id}`,
                'styleId': 'style_blue',
                'paths': pl
            }])
        }
    })

}

function addVolunteerPoint(lat, lon, username) {
    markerLayer.add([{
        id: `${username}`,   //点标记唯一标识，后续如果有删除、修改位置等操作，都需要此id
        styleId: 'myStyle',  //指定样式id
        position: new TMap.LatLng(lat, lon),  //点标记坐标位置
    }])
}

function clickVolunteer(e) {
    console.log(e.point)
    let username = e.geometry.id
    $.ajax({
        url: '/map/getVolunteer',
        type: 'get',
        async: false,
        data: {
            username: username
        },
        success: (data) => {
            showClickVolunteer(data)
        }
    })
}

function showClickVolunteer(volunteer) {
    $('#click-volunteer-box').html(`
        <div class="py-8 px-8 max-w-xs bg-white rounded-xl bg-opacity-60 shadow-md space-y-2 sm:py-4 sm:flex sm:items-center sm:space-y-0 sm:space-x-6">
      <div class="text-center space-y-2 sm:text-left">
        <div class="space-y-0.5">
           <span onclick="$('#click-volunteer-box').hide()" class="close float-right cursor-pointer">&times;</span>
          <div class="flex text-center px-2 items-center">
            <p class="text-lg text-black font-semibold mr-2">
              ${volunteer.username}
            </p>
            <p class="text-gray-400 text-md">${volunteer.score}</p>

          </div>
          <div class="flex text-center items-center justify-between">
            <p class="h-7 px-2 text-gray-500 font-medium items-center
            ">
              ${volunteer.place}
            </p>
            <button id="buffer-${volunteer.lat}-${volunteer.lon}" onclick="generateBuffer(event)" class="px-4 py-1 float-right text-sm text-purple-600 font-semibold rounded-full border border-purple-200 hover:text-white hover:bg-purple-600 hover:border-transparent focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2">
              缓冲区
            </button>
          </div>

          <div class="flex space-x-3 my-4 text-sm font-semibold">
            <div class="flex-auto flex space-x-3">
              <button class="px-4 py-1 text-sm text-purple-600 font-semibold rounded-full border border-purple-200 hover:text-white hover:bg-purple-600 hover:border-transparent focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2">发起请求</button>
              <button class="px-4 py-1 text-sm text-purple-600 font-semibold rounded-full border border-purple-200 hover:text-white hover:bg-purple-600 hover:border-transparent focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-offset-2">举报</button>
            </div>
            <button class="flex-none flex items-center justify-center w-9 h-9 rounded-full bg-purple-50 text-purple-700" type="button" aria-label="like">
              <svg width="20" height="20" fill="currentColor">
                <path fill-rule="evenodd" clip-rule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" />
              </svg>
            </button>
          </div>
        </div>
      </div>
    </div>
    `)
    $('#click-volunteer-box').show()
}

function generateBuffer(event) {
    let array = $(event.target).attr('id').split('-')
    let lat = array[1]
    let lon = array[2]
    circleLayer.add([{
        styleId: 'circle',
        center: new TMap.LatLng(lat, lon),
        radius: 500
    }])
}

function darkSwitch() {
    let button = $('#switch')
    if (button.hasClass('dark')) {
        button.html('<svg t="1649697374107" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7914" width="30" height="30"><path d="M419.8 379.42l-1.15 1.98c1.49-0.52 2.94-1.18 4.36-1.98h-3.21zM484 450.51h14.75l-18.03-31.23-11.34 19.64A21.43 21.43 0 0 1 484 450.51zM467.09 442.9l-4.39 7.61h16.34c-2.64-4.05-6.95-6.92-11.95-7.61z" fill="#FFFFFF" p-id="7915"></path><path d="M839.12 541.74v-59.48h118.95v59.48H839.12zM722.28 259.68l84.1-84.13 42.05 42.05-84.1 84.13-42.05-42.05zM512 749.9c-131.38 0-237.9-106.52-237.9-237.9S380.62 274.1 512 274.1 749.9 380.62 749.9 512 643.35 749.9 512 749.9z m0-416.72c-98.76 0-178.82 80.05-178.82 178.82S413.24 690.82 512 690.82 690.82 610.76 690.82 512 610.76 333.18 512 333.18zM482.26 65.93h59.48v118.95h-59.48V65.93zM175.55 217.59l42.05-42.05 84.1 84.13-42.05 42.05-84.1-84.13z m9.33 324.15H65.93v-59.48h118.95v59.48z m116.81 222.58l-84.1 84.1-42.05-42.05 84.1-84.13 42.05 42.08z m240.05 193.75h-59.48V839.12h59.48v118.95z m306.69-151.69l-42.05 42.05-84.1-84.13 42.05-42.05 84.1 84.13z m0 0" fill="#FFCC00" p-id="7916"></path></svg>')
        document.documentElement.classList.remove('dark')
        map.setMapStyleId('style2')
        button.removeClass('dark')
    }
    else {
        button.html('<svg t="1649697580192" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="14548" width="30" height="30"><path d="M826.66699999 490.667L803.19999999 552.533h-61.867l51.2 38.4-23.466 70.4 57.6-42.666 57.6 42.666-23.467-70.4 51.2-38.4h-61.867l-23.466-61.866zM555.73299999 448l57.6-42.667 57.6 42.667-23.466-70.4 51.2-38.4H636.79999999l-23.467-61.867-23.466 61.867H527.99999999l51.2 38.4-23.467 70.4z m441.6-320H911.99999999l-32-85.333L847.99999999 128h-85.333l70.4 53.333-32 96 81.066-59.733 81.067 59.733-32-96L997.33299999 128zM378.66699999 339.2c0-113.067 40.533-215.467 106.666-296.533C246.39999999 64 58.66699999 266.667 58.66699999 512c0 260.267 209.066 469.333 469.333 469.333 147.2 0 298.667-68.266 384-172.8-14.933 2.134-49.067 2.134-64 2.134-260.267 0-469.333-211.2-469.333-471.467zM527.99999999 938.667c-234.667 0-426.667-192-426.667-426.667 0-187.733 119.467-349.867 292.267-405.333-36.267 72.533-57.6 153.6-57.6 234.666 0 268.8 204.8 488.534 467.2 512-76.8 53.334-177.067 85.334-275.2 85.334z" p-id="14549" fill="#13227a"></path></svg>')
        document.documentElement.classList.add('dark')
        map.setMapStyleId('style1')
        button.addClass('dark')
    }
}

function clickPath(e) {
    let h_id = e.geometry.id
    $('#waiting-request-box').html(
        `<div class="border-2 rounded-xl bg-purple-50 dark:bg-slate-700">
      <div>
        <span onclick="$('#waiting-request-box').hide()" class="close dark:text-white float-right cursor-pointer mr-2">&times;</span>
      </div>
      <div class="px-10 py-6 space-y-8">


        <div class="flex text-center items-center">
          <h1 class="font-semibold text-2xl dark:text-white">您正在处理这个请求</h1>
          <svg width="40px" height="40px" viewBox="0 0 384 578" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
            <!-- Generator: Sketch 63 (92445) - https://sketch.com -->
            <title>走路男</title>
            <desc>Created with Sketch.</desc>
            <defs>
              <path d="M0.895376054,20.394849 C1.59369575,33.9598964 1.94285559,43.4636192 1.94285559,48.9060175 C1.94285559,57.069615 67.7071708,60.8088418 82.9469711,56.3061911 C88.523453,55.0633991 97.9445685,48.9234561 97.9445685,45.6070188 C97.9445685,43.3960607 97.4213454,40.7690946 96.3748992,37.7261207 C91.446488,33.0539462 81.3207233,28.6311902 65.9976051,24.4578528 C46.7422728,13.2653615 40.3638083,9.132797 30.8775887,3.38154142 C25.588917,1.65627955 19.5607019,12.5298256 21.4940631,18.6449808 C19.6975597,18.6449808 14.9425688,21.8858507 8.54027158,18.6449808 C5.79086318,17.2532186 3.24256467,17.836508 0.895376054,20.394849 Z" id="path-1"></path>
              <path d="M0.895376054,20.394849 C1.59369575,33.9598964 1.94285559,43.4636192 1.94285559,48.9060175 C1.94285559,57.069615 67.7071708,60.8088418 82.9469711,56.3061911 C88.523453,55.0633991 97.9445685,48.9234561 97.9445685,45.6070188 C97.9445685,43.3960607 97.4213454,40.7690946 96.3748992,37.7261207 C91.446488,33.0539462 81.3207233,28.6311902 65.9976051,24.4578528 C46.7422728,13.2653615 40.3638083,9.132797 30.8775887,3.38154142 C25.588917,1.65627955 19.5607019,12.5298256 21.4940631,18.6449808 C19.6975597,18.6449808 14.9425688,21.8858507 8.54027158,18.6449808 C5.79086318,17.2532186 3.24256467,17.836508 0.895376054,20.394849 Z" id="path-3"></path>
            </defs>
            <g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
              <g id="iPhone-8" transform="translate(-113.000000, -388.000000)">
                <g id="编组-6" transform="translate(-87.000000, -14.000000)">
                  <g id="走路男" transform="translate(189.000000, 402.000000)">
                    <polygon id="路径-104" fill="#FFA788" points="258.431982 497.479539 273.777633 547.642299 295.845176 543.180355 286.0563 477.906809"></polygon>
                    <polygon id="路径-104" fill="#FFA788" transform="translate(92.665218, 403.369919) rotate(94.000000) translate(-92.665218, -403.369919) " points="75.1605248 387.777269 85.2663748 438.535298 110.169911 436.793873 102.784843 368.20454"></polygon>
                    <path d="M162.925719,269.351438 C158.939897,313.756614 158.939897,347.717737 162.925719,371.234809 C113.979787,379.593977 88.812376,383.807147 87.4234871,383.874318 L113.217138,423.528956 C175.439593,424.731833 208.195515,421.210007 211.484902,412.96348 C214.77429,404.716952 217.630347,393.943762 220.053075,380.643911 L258.337426,512.531002 L295.845176,489.794147 L250.211806,254.786125 L162.925719,269.351438 Z" id="路径-190" fill="#386E91"></path>
                    <path d="M267.138114,195.580702 C288.809017,213.834647 316.267216,224.990183 349.512711,229.047309 C356.489707,228.115183 363.796358,227.11511 371.432664,226.047092 C379.770647,229.406932 384.836888,232.974615 386.631386,236.75014 C387.114242,239.434136 386.267371,240.776135 384.090774,240.776135 C389.400639,243.55275 392.968321,248.571002 394.793821,255.830892 C395.051913,258.413486 394.139163,259.690445 392.055571,259.661768 C391.872789,262.279886 390.817881,263.392663 388.89085,263.000101 C388.425432,263.761781 387.678866,264.33028 384.938291,263.000101 C384.090774,265.153576 380.781893,263.000101 378.630162,261.541264 C376.441034,260.215541 369.950381,255.800084 363.995675,253.756278 C360.025871,252.393741 352.542121,251.09437 341.544426,249.858166 C283.0628,243.335854 251.511305,233.730148 246.889943,221.041047 C242.169374,205.062624 244.252191,196.575842 253.138393,195.580702 L267.138114,195.580702 Z" id="路径-187" fill="#FFA788"></path>
                    <path d="M270.051777,125.633991 C269.643994,167.724937 270.885946,191.068545 273.777633,195.664812 C267.613105,200.608302 259.757829,207.767547 250.211806,217.142547 L270.051777,125.633991 Z" id="路径-183" fill="#B92C3F"></path>
                    <path d="M254.34747,112.030825 C264.817008,113.689869 270.051777,118.224258 270.051777,125.633991 C270.051777,136.748589 247.456892,226.653181 254.34747,266.465929 C224.626062,275.509983 117.460534,299.493893 108.590867,286.329675 C105.322741,281.19678 130.336434,223.097163 183.631944,112.030825 L254.34747,112.030825 Z" id="路径-182" fill="#F73E4C"></path>
                    <path d="M182.547374,139.68564 C179.670574,163.547867 171.210911,206.006118 157.168384,267.060392 L125.729539,229.745599 C156.483507,181.213563 175.422785,151.193576 182.547374,139.68564 Z" id="路径-198" fill="#DC2D3A"></path>
                    <path d="M133.807106,210.697235 C146.674712,243.880145 159.701359,266.69126 172.887044,279.130579 C176.948821,283.009218 186.581008,287.343957 201.783606,292.134797 C206.790168,297.480572 211.003855,301.292783 214.424665,303.571429 C217.845476,305.850074 216.865555,307.08292 211.484902,307.269965 C211.571191,307.159392 212.17179,307.307426 213.286699,307.714069 C214.600795,308.187236 214.742823,313.795738 210.707915,315.056937 C212.593804,316.968016 207.763889,320.909288 205.655948,320.571367 C206.539117,322.358437 202.712309,325.257123 199.975609,325.257123 C199.697366,326.337736 196.917651,327.255007 194.587077,327.255007 C186.430561,327.255007 180.258541,325.405738 178.357732,324.724857 C173.734561,321.592882 170.065476,317.575025 161.351594,300.47433 C153.769283,290.032862 96.624876,229.182168 97.9401352,213.475012 C98.8169746,203.003576 103.30632,192.617653 111.408172,182.317243 L133.807106,210.697235 Z" id="路径-184" fill="#FFA788"></path>
                    <path d="M186.978609,112.030825 C177.454799,114.299833 170.34036,116.820126 165.635293,119.591704 C158.577691,123.74907 108.391679,159.148686 105.417039,175.996714 C103.433945,187.228733 120.898396,206.469081 157.810392,233.717758 L180.88892,151.836868 L186.978609,112.030825 Z" id="路径-181" fill="#F93B50"></path>
                    <path d="M234.458922,142.195638 C233.524213,137.918398 230.952856,135.734695 226.744854,135.644531 C210.227705,135.290621 193.005782,127.659195 186.978609,122.735305 C180.960348,116.616126 178.840588,112.030825 178.232174,109.110708 C180.888269,104.955667 193.785094,95.6573971 203.794085,90.5087426 C224.737992,88.0559689 239.519221,89.7721871 248.137773,95.6573971 C256.632316,102.11158 260.879588,107.223807 260.879588,110.994079 C258.889261,118.283162 255.075629,123.471602 249.438694,126.5594 L246.457853,140.031118 L240.326435,140.031118 L243.027096,125.633991 L245.863002,117.062717 L224.403344,117.062717 C231.207461,122.690488 235.849778,127.758408 238.330295,132.266478 C239.828908,134.990043 239.807927,137.524414 239.807927,138.04021 C239.20003,138.631185 237.417028,140.016328 234.458922,142.195638 Z" id="路径-180" fill="#B92C3F"></path>
                    <path d="M266.869947,33.4736173 C272.051439,41.9604539 274.564095,49.3155671 274.407914,55.5389571 C274.173642,64.8740421 277.652437,64.9348183 279.830714,69.2948599 C279.8012,71.6743621 278.272508,73.4904325 275.244636,74.7430711 C274.393669,84.9527995 272.117449,91.4399001 268.415977,94.2043728 C264.649055,97.0177266 254.979067,98.2324994 249.711511,98.2324994 C248.192414,106.544906 248.192414,113.322445 251.268586,116.975524 C251.831321,118.034107 249.468954,123.253679 246.675226,126.985092 C245.910148,128.006959 245.436098,134.426133 244.341967,137.246559 C244.341967,137.246559 240.397521,137.852919 239.807927,138.04021 C238.812764,134.284707 235.647078,129.693679 233.034091,128.686233 C220.924231,124.017237 215.538742,119.592058 210.740079,112.598431 C217.348152,103.902375 219.970533,100.040303 222.068979,85.6611948 C216.151217,78.679548 212.095899,72.5509724 209.903026,67.2754681 L220.924231,35.0899833 L266.869947,33.4736173 Z" id="路径-179" fill="#FFA788"></path>
                    <path d="M221.860104,88.0413721 C220.598064,83.8641131 214.500749,75.9101666 203.568158,64.1795325 C195.266214,57.0711651 190.968564,21.9780816 219.967045,21.9780816 C218.955088,20.2109685 215.07054,19.6552579 208.313399,20.3109499 C213.730737,15.2638269 218.827722,14.1906415 223.604353,17.0913938 C231.536985,4.8781622 252.989583,13.6455233 263.689143,0.375899058 C271.809338,4.87893725 279.19091,20.7666791 268.509952,34.0812562 C256.548611,44.1545759 244.781033,43.5639881 242.954241,43.5639881 C239.210738,48.2411541 237.338987,53.9747127 237.338987,60.7646639 L234.540303,55.1316034 L231.037853,68.9945738 C230.259704,66.1558254 229.355221,64.1126503 228.324405,62.8650484 C226.893663,59.4932407 216.589766,56.7983932 216.589766,65.2491009 C216.589766,71.385427 220.024399,75.2068091 226.893663,76.7132471 L226.893663,83.5329086 L221.860104,88.0413721 Z" id="路径-178" fill="#5E120F"></path>
                    <path d="M193.432615,296.494859 C197.731303,301.193827 200.993405,304.111024 203.194966,305.236869 C205.397132,306.363024 207.393816,306.831942 210.219918,306.931575 L211.484902,306.952505 L211.484902,307.587426 C207.867439,307.587426 205.522987,307.140509 202.905884,305.802162 C200.998706,304.82686 198.385061,302.611263 195.051085,299.149827 L192.964149,296.923419 L193.432615,296.494859 Z" id="路径-185" fill="#DE5728" fill-rule="nonzero"></path>
                    <path d="M196.82146,311.810914 L197.037481,311.213872 L199.417422,312.02735 L202.43258,312.954046 L203.536689,313.260137 C204.492647,313.515342 205.489616,313.755561 206.498045,313.978666 L209.215886,314.535589 L210.033437,314.68348 L209.926849,315.30939 L207.889325,314.922459 L205.600096,314.426488 L203.191615,313.82485 L201.290754,313.279991 L199.220091,312.630836 L196.82146,311.810914 Z" id="路径-186" fill="#DE5728" fill-rule="nonzero"></path>
                    <path d="M190.708772,316.454042 L191.002041,315.89091 L192.096064,316.428386 C192.742907,316.731084 193.527154,317.075446 194.393257,317.419742 C195.033648,317.674313 195.661178,317.903913 196.268762,318.103357 L197.350662,318.4318 L197.53674,318.482421 C199.004542,318.873384 200.537429,319.233763 202.07047,319.562237 L204.113028,319.978623 L203.995587,320.602587 L201.93745,320.183067 C200.90913,319.962736 199.880741,319.728106 198.882488,319.482456 L196.989288,318.989582 C196.088596,318.73132 195.137587,318.398879 194.158713,318.009754 L192.526659,317.322701 C192.030542,317.10192 191.587737,316.893481 191.214476,316.709694 L190.708772,316.454042 Z" id="路径-186" fill="#DE5728" fill-rule="nonzero"></path>
                    <path d="M185.896555,321.660826 L186.112575,321.063784 L187.58581,321.576834 C188.4423,321.865559 189.459159,322.19379 190.548921,322.521948 L192.611784,323.110049 C193.567741,323.365254 194.56471,323.605473 195.573139,323.828577 L199.108532,324.533391 L199.001944,325.159301 L197.612931,324.90169 L194.675191,324.276399 L192.26671,323.674761 L190.365849,323.129902 C189.268405,322.799431 188.244808,322.469033 187.382005,322.178164 L185.896555,321.660826 Z" id="路径-186" fill="#DE5728" fill-rule="nonzero"></path>
                    <path d="M369.884987,236.033148 C374.010446,238.966026 378.727244,240.439008 384.035378,240.452092 C384.049287,240.432466 384.008734,240.611384 384.035378,240.628197 L384.023873,241.086908 C378.839149,241.086908 374.170623,239.661664 370.018295,236.811175 C365.591599,241.530142 362.200655,242.964873 355.520719,242.308233 L354.230394,242.159714 L354.312637,241.530142 C361.632436,242.486358 365.125923,241.160375 369.884987,236.033148 Z" id="路径" fill="#DE5728" fill-rule="nonzero"></path>
                    <path d="M382.265206,244.673562 C386.08461,247.114603 389.13848,251.204807 391.432157,256.935432 L392.038861,258.538995 L391.441003,258.752749 C389.325682,252.836323 386.481621,248.552838 382.914161,245.89355 L381.923286,245.208553 L382.265206,244.673562 Z" id="路径" fill="#DE5728" fill-rule="nonzero"></path>
                    <path d="M378.496698,249.361041 C379.199242,249.731971 382.859403,252.938883 385.173179,255.866222 C386.250624,257.229382 387.226078,258.682184 388.08218,260.231464 L388.897856,261.813156 L388.325421,262.087823 C387.313659,259.979207 386.083495,258.041845 384.675066,256.259932 C382.806762,253.896194 378.895043,250.346141 378.073472,249.731971 L378.496698,249.361041 Z" id="路径" fill="#DE5728" fill-rule="nonzero"></path>
                    <path d="M374.42833,254.062262 L374.5934,254.079682 C378.612875,255.635557 382.112321,258.314414 385.088909,262.110745 C385.19709,262.24872 385.172938,262.448268 385.034964,262.556449 C384.89699,262.664631 384.697441,262.640479 384.58926,262.502505 C381.681154,258.793514 378.273745,256.185112 374.364204,254.671791 C374.200698,254.6085 374.119457,254.424645 374.182748,254.261138 C374.224942,254.152134 374.32072,254.079692 374.42833,254.062262 Z" id="路径" fill="#DE5728" fill-rule="nonzero"></path>
                    <g id="编组-12" transform="translate(266.227818, 519.721525)">
                      <mask id="mask-2" fill="white">
                        <use xlink:href="#path-1"></use>
                      </mask>
                      <use id="路径-106" fill="#FFFFFF" xlink:href="#path-1"></use>
                      <path d="M78.5357763,27.8638083 C79.8018198,28.5617868 80.4348416,29.3928338 80.4348416,30.3569491 C80.4348416,36.2840348 77.0430308,38.4773375 73.2619513,38.960581 C66.6860496,39.8010185 61.8295932,37.7691673 52.9515827,34.8298572 C51.0352836,34.1954136 51.8988715,32.7524337 51.8988715,32.7524337 C52.4051727,30.3942161 45.7783694,32.0587642 32.0184617,37.746078 C25.6434203,40.1487665 22.4558997,44.9912939 22.4558997,52.2736599 C13.3508201,52.2736599 10.09623,51.9044607 12.6921295,51.1660621 C12.8885858,48.2007225 12.1586458,44.8612921 10.5023096,41.147771 C8.86210153,37.5974431 5.36133165,35.5490398 1.12784561e-14,35.002561 L1.94285559,10.8844091 L14.0504867,10.8844091 L22.4558997,10.8844091 L78.5357763,27.8638083 Z" id="路径-194" fill="#FACACA" mask="url(#mask-2)"></path>
                      <path d="M66.68023,22.6837643 C61.8871941,33.2828257 56.5615054,37.042333 50.7031638,33.9622861 C50.1968626,33.9622861 39.0914998,27.9391173 17.3870753,15.8927796 L27.9386006,-8.45884209e-14 L66.68023,22.6837643 Z" id="路径-193" fill="#B92C3F" mask="url(#mask-2)"></path>
                      <path d="M0,43.8348679 C9.11975033,47.8628007 20.3314887,50.5869709 33.6352152,52.0073785 C46.9346788,53.125775 73.8164993,53.8802858 79.0046813,52.0073785 C93.8443623,47.6601252 97.9445685,40.6463139 97.9445685,37.3085627 C97.9445685,35.0833953 99.0984881,38.0582941 101.406328,46.2332589 L97.1358042,53.8802858 L81.8328373,61.0045418 L0,57.0618645 L0,43.8348679 Z" id="路径-192" fill="#B92C3F" mask="url(#mask-2)"></path>
                      <path d="M19.8073614,13.3996388 C40.8933609,25.5847103 52.5975142,31.7675394 54.9198211,31.9481259 C58.4032816,32.2190058 61.8747287,27.4009099 63.1434849,24.3669782 C60.3148122,22.6175621 47.8794643,15.2171947 25.8374411,2.16587612 L19.8073614,13.3996388 Z" id="路径-195" fill="#7C1422" mask="url(#mask-2)"></path>
                      <path d="M32.5280568,4.72435361 L33.1617052,5.3994472 L32.9504723,9.25602653 C32.923274,9.86510093 32.9001911,10.4581358 32.8813918,11.0363385 L32.8439402,12.8274338 C36.0156889,11.6013864 38.475838,10.8699073 40.2321512,10.6188401 L40.9635867,10.5393889 L41.4507722,10.5204595 L42.0427982,10.869928 C42.8764726,12.5297533 35.158351,24.3886563 33.2417235,23.5070247 C32.1544441,22.7557198 31.6764189,20.3265749 31.5737525,16.3055413 L31.5492063,14.7047619 L31.4089666,14.7679258 C30.0964104,15.3078431 28.6803148,15.9204386 27.1611793,16.6061598 L23.9856702,18.0752354 L23.3008435,17.983221 C21.0849143,16.0826695 27.8907121,5.64786107 32.0073209,4.78159327 L32.5280568,4.72435361 Z M40.8380952,11.8222222 L40.4197004,11.874548 C38.8913713,12.0912395 36.7103483,12.7230579 33.8937406,13.7858028 L32.8190476,14.2031746 L32.8248303,15.0318197 C32.8558778,18.521854 33.1383244,20.9849029 33.5707689,21.9775939 L33.7203334,22.2534251 L33.8652407,22.4065966 C34.3354183,22.6201622 39.1990111,15.3001864 40.5660105,12.4845159 L40.7794209,12.0123015 L40.8380952,11.8222222 Z M31.8412698,6.14603175 L31.5273922,6.27408223 C28.823688,7.62038759 24.7420751,13.4674891 24.0692984,15.9692561 L23.9790524,16.4512855 L23.9873016,16.6730159 L25.0761675,16.163036 L28.1382556,14.7808671 L30.9271561,13.5930413 L31.5555556,13.3333333 L31.5683819,12.7044949 C31.5887105,11.5941082 31.6269515,10.4301883 31.6817432,9.2026508 L31.8412698,6.14603175 Z" id="路径-196" fill="#000000" fill-rule="nonzero" mask="url(#mask-2)"></path>
                      <path d="M47.8881836,13.9780583 L48.521832,14.6531519 C48.4358545,16.0092756 48.3649958,17.2915825 48.3105972,18.5098318 L48.1981236,21.9821664 L48.2104032,22.0786896 C51.3793563,20.854015 53.8375441,20.1233231 55.5927166,19.8724821 L56.3237135,19.7930936 L56.810899,19.7741642 L57.402925,20.1236328 C58.2365994,21.783458 50.5184778,33.642361 48.6018503,32.7607294 C47.5145709,32.0094245 47.0365457,29.5802796 46.9339732,25.5625657 L46.9142857,23.9619048 L46.7690934,24.0216305 C45.0190185,24.7415203 43.0848734,25.5906157 40.9678426,26.5699774 L39.345797,27.3289401 L38.6609703,27.2369257 C36.4450411,25.3363742 43.2508389,14.9015658 47.3674477,14.035298 L47.8881836,13.9780583 Z M56.1968254,21.0793651 L55.7798358,21.1282494 C54.469891,21.313965 52.6807254,21.8045517 50.4249695,22.6092393 L48.1777778,23.4539683 L48.1849571,24.2855244 C48.2160046,27.7755587 48.4984512,30.2386076 48.9308957,31.2312987 L49.0804602,31.5071298 L49.2253675,31.6603014 C49.6955451,31.873867 54.5591379,24.5538911 55.9261373,21.7382207 L56.1395477,21.2660062 L56.1968254,21.0793651 Z M47.2,15.3968254 L46.887519,15.527787 C44.1838148,16.8740923 40.1022019,22.7211938 39.4294252,25.2229608 L39.3391792,25.7049903 L39.3460317,25.9238095 L40.4363057,25.4167361 C41.5025426,24.9234972 42.5233136,24.4628045 43.49869,24.0344465 L46.2887069,22.8461658 L46.9142857,22.5904762 L46.9722657,20.2512091 L47.1363003,16.5660756 L47.2,15.3968254 Z" id="路径-196" fill="#000000" fill-rule="nonzero" mask="url(#mask-2)"></path>
                    </g>
                    <g id="编组-12" transform="translate(41.444444, 435.514323) rotate(101.000000) translate(-41.444444, -435.514323) translate(-9.349206, 403.768291)">
                      <mask id="mask-4" fill="white">
                        <use xlink:href="#path-3"></use>
                      </mask>
                      <use id="路径-106" fill="#FFFFFF" xlink:href="#path-3"></use>
                      <path d="M78.5357763,27.8638083 C79.8018198,28.5617868 80.4348416,29.3928338 80.4348416,30.3569491 C80.4348416,36.2840348 77.0430308,38.4773375 73.2619513,38.960581 C66.6860496,39.8010185 61.8295932,37.7691673 52.9515827,34.8298572 C51.0352836,34.1954136 51.8988715,32.7524337 51.8988715,32.7524337 C52.4051727,30.3942161 45.7783694,32.0587642 32.0184617,37.746078 C25.6434203,40.1487665 22.4558997,44.9912939 22.4558997,52.2736599 C13.3508201,52.2736599 10.09623,51.9044607 12.6921295,51.1660621 C12.8885858,48.2007225 12.1586458,44.8612921 10.5023096,41.147771 C8.86210153,37.5974431 5.36133165,35.5490398 1.12784561e-14,35.002561 L1.94285559,10.8844091 L14.0504867,10.8844091 L22.4558997,10.8844091 L78.5357763,27.8638083 Z" id="路径-194" fill="#FACACA" mask="url(#mask-4)"></path>
                      <path d="M66.68023,22.6837643 C61.8871941,33.2828257 56.5615054,37.042333 50.7031638,33.9622861 C50.1968626,33.9622861 39.0914998,27.9391173 17.3870753,15.8927796 L27.9386006,-8.45884209e-14 L66.68023,22.6837643 Z" id="路径-193" fill="#B92C3F" mask="url(#mask-4)"></path>
                      <path d="M0,43.8348679 C9.11975033,47.8628007 20.3314887,50.5869709 33.6352152,52.0073785 C46.9346788,53.125775 73.8164993,53.8802858 79.0046813,52.0073785 C93.8443623,47.6601252 97.9445685,40.6463139 97.9445685,37.3085627 C97.9445685,35.0833953 99.0984881,38.0582941 101.406328,46.2332589 L97.1358042,53.8802858 L81.8328373,61.0045418 L0,57.0618645 L0,43.8348679 Z" id="路径-192" fill="#B92C3F" mask="url(#mask-4)"></path>
                      <path d="M19.8073614,13.3996388 C40.8933609,25.5847103 52.5975142,31.7675394 54.9198211,31.9481259 C58.4032816,32.2190058 61.8747287,27.4009099 63.1434849,24.3669782 C60.3148122,22.6175621 47.8794643,15.2171947 25.8374411,2.16587612 L19.8073614,13.3996388 Z" id="路径-195" fill="#7C1422" mask="url(#mask-4)"></path>
                      <path d="M32.5280568,4.72435361 L33.1617052,5.3994472 L32.9504723,9.25602653 C32.923274,9.86510093 32.9001911,10.4581358 32.8813918,11.0363385 L32.8439402,12.8274338 C36.0156889,11.6013864 38.475838,10.8699073 40.2321512,10.6188401 L40.9635867,10.5393889 L41.4507722,10.5204595 L42.0427982,10.869928 C42.8764726,12.5297533 35.158351,24.3886563 33.2417235,23.5070247 C32.1544441,22.7557198 31.6764189,20.3265749 31.5737525,16.3055413 L31.5492063,14.7047619 L31.4089666,14.7679258 C30.0964104,15.3078431 28.6803148,15.9204386 27.1611793,16.6061598 L23.9856702,18.0752354 L23.3008435,17.983221 C21.0849143,16.0826695 27.8907121,5.64786107 32.0073209,4.78159327 L32.5280568,4.72435361 Z M40.8380952,11.8222222 L40.4197004,11.874548 C38.8913713,12.0912395 36.7103483,12.7230579 33.8937406,13.7858028 L32.8190476,14.2031746 L32.8248303,15.0318197 C32.8558778,18.521854 33.1383244,20.9849029 33.5707689,21.9775939 L33.7203334,22.2534251 L33.8652407,22.4065966 C34.3354183,22.6201622 39.1990111,15.3001864 40.5660105,12.4845159 L40.7794209,12.0123015 L40.8380952,11.8222222 Z M31.8412698,6.14603175 L31.5273922,6.27408223 C28.823688,7.62038759 24.7420751,13.4674891 24.0692984,15.9692561 L23.9790524,16.4512855 L23.9873016,16.6730159 L25.0761675,16.163036 L28.1382556,14.7808671 L30.9271561,13.5930413 L31.5555556,13.3333333 L31.5683819,12.7044949 C31.5887105,11.5941082 31.6269515,10.4301883 31.6817432,9.2026508 L31.8412698,6.14603175 Z" id="路径-196" fill="#000000" fill-rule="nonzero" mask="url(#mask-4)"></path>
                      <path d="M47.8881836,13.9780583 L48.521832,14.6531519 C48.4358545,16.0092756 48.3649958,17.2915825 48.3105972,18.5098318 L48.1981236,21.9821664 L48.2104032,22.0786896 C51.3793563,20.854015 53.8375441,20.1233231 55.5927166,19.8724821 L56.3237135,19.7930936 L56.810899,19.7741642 L57.402925,20.1236328 C58.2365994,21.783458 50.5184778,33.642361 48.6018503,32.7607294 C47.5145709,32.0094245 47.0365457,29.5802796 46.9339732,25.5625657 L46.9142857,23.9619048 L46.7690934,24.0216305 C45.0190185,24.7415203 43.0848734,25.5906157 40.9678426,26.5699774 L39.345797,27.3289401 L38.6609703,27.2369257 C36.4450411,25.3363742 43.2508389,14.9015658 47.3674477,14.035298 L47.8881836,13.9780583 Z M56.1968254,21.0793651 L55.7798358,21.1282494 C54.469891,21.313965 52.6807254,21.8045517 50.4249695,22.6092393 L48.1777778,23.4539683 L48.1849571,24.2855244 C48.2160046,27.7755587 48.4984512,30.2386076 48.9308957,31.2312987 L49.0804602,31.5071298 L49.2253675,31.6603014 C49.6955451,31.873867 54.5591379,24.5538911 55.9261373,21.7382207 L56.1395477,21.2660062 L56.1968254,21.0793651 Z M47.2,15.3968254 L46.887519,15.527787 C44.1838148,16.8740923 40.1022019,22.7211938 39.4294252,25.2229608 L39.3391792,25.7049903 L39.3460317,25.9238095 L40.4363057,25.4167361 C41.5025426,24.9234972 42.5233136,24.4628045 43.49869,24.0344465 L46.2887069,22.8461658 L46.9142857,22.5904762 L46.9722657,20.2512091 L47.1363003,16.5660756 L47.2,15.3968254 Z" id="路径-196" fill="#000000" fill-rule="nonzero" mask="url(#mask-4)"></path>
                    </g>
                    <polygon id="路径-197" fill="#B92C3F" points="235.107603 139.382208 219.555881 192.725384 223.992653 196.298751 236.014059 139.382208"></polygon>
                    <polygon id="路径-197" fill="#B92C3F" points="240.67482 138.82146 227.800859 195.580702 233.091136 195.580702 241.657971 138.82146"></polygon>
                    <path d="M226.681106,66.0909986 C226.132564,64.2725384 224.584597,61.0436818 220.917256,62.7673921 C217.249915,64.4911024 219.503953,70.3822545 222.636316,71.8645368 C225.339788,73.4743149 229.783823,73.5289559 229.783823,72.7240668 C229.783823,71.9191778 226.681106,71.0406591 226.681106,66.0909986 Z" id="路径-200" fill="#EF5F32"></path>
                    <path d="M258.175055,55.9781933 C259.665055,56.0483967 261.054219,56.3217055 262.319974,56.8242523 C262.808837,57.0183476 263.047794,57.5719952 262.853699,58.0608589 C262.659604,58.5497227 262.105956,58.7886798 261.617092,58.5945845 C260.559028,58.1744973 259.375384,57.9416234 258.085409,57.8808445 C255.857685,57.7758821 253.439341,58.180698 251.031044,58.9228367 C249.738487,59.3211503 248.746622,59.7176832 248.198474,59.9750935 C247.722371,60.198671 247.155168,59.9939589 246.931591,59.5178561 C246.708013,59.0417534 246.912725,58.4745505 247.388828,58.250973 L248.343744,57.843213 C248.920256,57.6155175 249.638826,57.3587104 250.470105,57.1025444 C252.551263,56.4612162 254.647674,56.0516988 256.671842,55.9733287 L258.175055,55.9781933 Z" id="路径" fill="#8E3737" fill-rule="nonzero"></path>
                    <path d="M258.734542,70.8129883 C260.487827,70.8129883 261.478411,68.4045216 261.478411,66.3335891 C261.478411,64.2626566 260.487827,61.9334387 258.734542,61.9334387 C256.981257,61.9334387 256.145682,64.5803042 256.145682,66.3335891 C256.145682,68.086874 256.981257,70.8129883 258.734542,70.8129883 Z" id="椭圆形" fill="#5E120F"></path>
                    <path d="M259.094375,81.7348195 C259.699258,81.3411215 266.57215,80.7287977 267.27561,81.4997645 C267.949322,83.207005 265.09477,87.7044212 262.82804,87.7044212 C261.337815,87.8740416 257.745855,83.3622195 259.094375,81.7348195 Z" id="路径-420" fill="#D33A07" transform="translate(263.086575, 84.419501) rotate(15.000000) translate(-263.086575, -84.419501) "></path>
                    <path d="M254.142857,50.7936508 C262.909282,50.7936508 270.015873,57.9002421 270.015873,66.6666667 C270.015873,75.4330913 262.909282,82.5396825 254.142857,82.5396825 C245.376433,82.5396825 238.269841,75.4330913 238.269841,66.6666667 C238.269841,57.9002421 245.376433,50.7936508 254.142857,50.7936508 Z M254.142857,52.6984127 C246.428403,52.6984127 240.174603,58.952213 240.174603,66.6666667 C240.174603,74.3811203 246.428403,80.6349206 254.142857,80.6349206 C261.857311,80.6349206 268.111111,74.3811203 268.111111,66.6666667 C268.111111,58.952213 261.857311,52.6984127 254.142857,52.6984127 Z" id="椭圆形" fill="#000000" fill-rule="nonzero" transform="translate(254.142857, 66.666667) rotate(-6.000000) translate(-254.142857, -66.666667) "></path>
                  </g>
                </g>
              </g>
            </g>
          </svg>
        </div>
        <div class="flex justify-center">
          <button id="${h_id}" onclick="finishRequest(event)" class="px-2 py-1 border-2 rounded-xl bg-purple-200 dark:text-white dark:bg-purple-500 dark:border-slate-700">完成请求</button>
        </div>

      </div>
    </div>`
    )
    $('#waiting-request-box').show()
}

function grade(id) {
    let gold = '<svg t="1649693295916" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2843" width="30" height="30"><path d="M313.991837 914.285714c-20.37551 0-40.228571-6.269388-56.946939-18.808163-30.302041-21.942857-44.930612-58.514286-38.661225-95.085714l24.032654-141.061225c3.134694-18.285714-3.134694-36.571429-16.195919-49.110204L123.297959 509.910204c-26.644898-26.122449-36.04898-64.261224-24.555102-99.787755 11.493878-35.526531 41.795918-61.126531 78.889796-66.35102l141.583674-20.375511c18.285714-2.612245 33.959184-14.106122 41.795918-30.30204l63.216326-128.522449C440.946939 130.612245 474.383673 109.714286 512 109.714286s71.053061 20.897959 87.24898 54.334694L662.987755 292.571429c8.359184 16.195918 24.032653 27.689796 41.795918 30.30204l141.583674 20.375511c37.093878 5.22449 67.395918 30.82449 78.889796 66.35102 11.493878 35.526531 2.089796 73.665306-24.555102 99.787755l-102.4 99.787755c-13.061224 12.538776-19.330612 31.346939-16.195919 49.110204l24.032654 141.061225c6.269388 37.093878-8.359184 73.142857-38.661225 95.085714-30.302041 21.942857-69.485714 24.555102-102.4 7.314286L538.122449 836.440816c-16.195918-8.359184-35.526531-8.359184-51.722449 0l-126.955102 66.87347c-14.628571 7.314286-30.302041 10.971429-45.453061 10.971428z m162.481632-96.653061z" fill="#f4ea2a" p-id="2844"></path></svg>'
    if ($('#'+id).hasClass('dark')) {
        for (let i = 1; i <= parseInt(id); i++) {
            $('#'+String(i)).html(gold)
            $('#'+String(i)).removeClass('dark')
        }
    }
    else {
        for (let i = 5; i >= parseInt(id); i--) {
            if (!$('#'+i).hasClass('dark')) {
                $('#'+i).html('<svg t="1649693295916" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2843" width="30" height="30"><path d="M313.991837 914.285714c-20.37551 0-40.228571-6.269388-56.946939-18.808163-30.302041-21.942857-44.930612-58.514286-38.661225-95.085714l24.032654-141.061225c3.134694-18.285714-3.134694-36.571429-16.195919-49.110204L123.297959 509.910204c-26.644898-26.122449-36.04898-64.261224-24.555102-99.787755 11.493878-35.526531 41.795918-61.126531 78.889796-66.35102l141.583674-20.375511c18.285714-2.612245 33.959184-14.106122 41.795918-30.30204l63.216326-128.522449C440.946939 130.612245 474.383673 109.714286 512 109.714286s71.053061 20.897959 87.24898 54.334694L662.987755 292.571429c8.359184 16.195918 24.032653 27.689796 41.795918 30.30204l141.583674 20.375511c37.093878 5.22449 67.395918 30.82449 78.889796 66.35102 11.493878 35.526531 2.089796 73.665306-24.555102 99.787755l-102.4 99.787755c-13.061224 12.538776-19.330612 31.346939-16.195919 49.110204l24.032654 141.061225c6.269388 37.093878-8.359184 73.142857-38.661225 95.085714-30.302041 21.942857-69.485714 24.555102-102.4 7.314286L538.122449 836.440816c-16.195918-8.359184-35.526531-8.359184-51.722449 0l-126.955102 66.87347c-14.628571 7.314286-30.302041 10.971429-45.453061 10.971428z m162.481632-96.653061z" fill="#dbdbdb" p-id="2844"></path></svg>')
                $('#'+i).addClass('dark')
            }
        }
    }
}

// 向服务器发送评分
function submitGrade(event) {
    let h_id = $(event.target).attr('id').split('-')[1]
    $.ajax({
        url: '/map/finishRequest',
        type: 'get',
        data: {
            h_id: h_id
        }
    })
    $('#grade-box').hide()
    polylineLayer.remove([`${h_id}`])
    markerLayer.remove(['destination'])
}

function detectKey(event) {
    if (event.keyCode == 13) {
        search()
        return false
    }
}

function search() {
    let content = $('#search-content').val()
    $.ajax({
        url: '/map/search',
        type: 'get',
        data: {
            content: content
        },
        success: (data) => {
            if (data.status == 'place') {
                let center = new TMap.LatLng((data.maxLat + data.minLat) / 2, (data.maxLon + data.minLon) / 2)
                map.setCenter(center)
                map.setZoom(11)
            }
            else if (data.status == 'volunteer') {
                let volunteer = data.volunteer
                let center = new TMap.LatLng(volunteer.lat, volunteer.lon)
                map.setCenter(center)
                map.setZoom(17)
                showClickVolunteer(volunteer)
            }
        }
    })
}

function generateHeatmap() {
    $.ajax({
        url: '/map/getAllVolunteers',
        type: 'get',
        async: false,
        success: data => {
            showHeatMap(data)
        }
    })
}

function showHeatMap(volunteers) {
    let heatPoints = []
    for (let i = 0; i < volunteers.length; i++) {
        heatPoints.push({"lng": volunteers[i].lon, "lat": volunteers[i].lat, "count": 1})
    }
    console.log(heatPoints)
    console.log(heatData)
    heat = new TMap.visualization.Heat({
        max: 1, // 热力最强阈值
        min: 0, // 热力最弱阈值
        height: 0, // 峰值高度
        gradientColor: { // 渐变颜色
            0.6: "#673198",
            0.8: "#e53390",
            0.9: "#ffc95a",
        },
        radius: 30 // 最大辐射半径

    }).addTo(map).setData(heatPoints)//设置数据

    markerLayer.setVisible(false)

}

function loadOGC() {
    wfsLayer.setVisible(true)
}

function clearOGC() {
    wfsLayer.setVisible(false)
}

// 打开用户向志愿者发起请求框
function requestVolunteer(event) {
    let username = $(event.target).attr('id').split('-')[1]
    let box = $('#request-box')
    box.html(`
    <div id="request-box" class="flex-none flex fixed justify-center items-center z-10 h-full w-full">
    
    <div id="request" class="p-3 rounded-lg bg-white dark:bg-slate-700 h-3/5 z-50 flex-col">
      <span onclick="$('#request-box').hide()" class="close dark:text-white float-right cursor-pointer">&times;</span>
      <textarea id="request-content" placeholder="请输入您的请求" required="required" class="w-full h-40 dark:text-white rounded-md bg-transparent outline-none"></textarea>
      <div class="flex items-center space-x-3 w-full">
        <div>
          <input type="radio" name="kind" value="study"><label class="dark:text-white">学习</label>
          <input type="radio" name="kind" value="life"><label class="dark:text-white">生活</label>
        </div>
        <div>
          <button id="submit-request-${username}" onclick="submitRequestTo(event)" class="py-1 mr-2 px-4 border-2 rounded-xl bg-white text-purple-400 hover:text-white hover:bg-purple-400">提交</button>
        </div>
    </div>
      </div>
      
  </div>
    `)
    box.show()
}

// 打开举报志愿者框
function reportVolunteer(event) {
    let username = $(event.target).attr('id').split('-')[1]
    $('#report-box').html(`
    <div class="bg-white dark:bg-slate-700 shadow overflow-hidden sm:rounded-lg">
      <div class="flex px-4 py-5 sm:px-6 justify-between">
        <h3 class="text-lg leading-6 font-medium dark:text-white text-gray-900">举报</h3>
        <span onclick="$('#report-box').hide()" class="close float-right cursor-pointer">&times;</span>
      </div>
      <div class="border-t border-gray-200 px-5">
        <div class="bg-white dark:bg-slate-700 px-4 py-5 flex space-x-4">
          <p class="text-gray-500 font-medium dark:text-gray-300 text-sm">举报内容</p>
          <textarea id="report-content" class="bg-gray-200 rounded-md outline-none"></textarea>
        </div>
        <div class="bg-white dark:bg-slate-700 px-4 py-5 flex justify-center">
          <button id="submit-report-${username}" onclick="submitReportVolunteer(event)" class="rounded-xl px-3 py-1 border-2 bg-white border-purple-200 text-purple-400 hover:bg-purple-400 hover:text-white">提交</button>
        </div>
        </dl>
      </div>
    </div>
  </div>
    `)
    $('#report-box').show()
}

// 提交举报
function submitReportVolunteer(event) {
    let username = $(event.target).attr('id').split('-')[2]
    $.ajax({
        url: '/map/submitReport',
        type: 'get',
        data: {
            reported: username,
            content: $('#report-content').val()
        }
    })
    $('#report-box').hide()
}

// 收藏志愿者
function addToFavorite(id) {
    let button = $(`#${id}`)
    let username = id.split('-')[3]
    let type   // 添加或取消收藏
    if (button.hasClass('dark')) {
        button.html(`<svg t="1650335767601" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2770" width="20" height="20"><path d="M923 283.6c-13.4-31.1-32.6-58.9-56.9-82.8-24.3-23.8-52.5-42.4-84-55.5-32.5-13.5-66.9-20.3-102.4-20.3-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5-24.4 23.9-43.5 51.7-56.9 82.8-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3 0.1-35.3-7-69.6-20.9-101.9z" p-id="2771" fill="#d81e06"></path></svg>`)
        button.removeClass('dark')
        type = 'add'
    }
    else {
        button.html(`<svg t="1650335767601" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2770" width="20" height="20"><path d="M923 283.6c-13.4-31.1-32.6-58.9-56.9-82.8-24.3-23.8-52.5-42.4-84-55.5-32.5-13.5-66.9-20.3-102.4-20.3-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5-24.4 23.9-43.5 51.7-56.9 82.8-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3 0.1-35.3-7-69.6-20.9-101.9z" p-id="2771" fill="#ffffff"></path></svg>`)
        button.addClass('dark')
        type = 'cancel'
    }
    $.ajax({
        url: '/map/addToFavorite',
        type: 'get',
        data: {
            username: username,
            type: type
        }
    })
}